package com.group.service.impl.patent;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.group.service.patent.PatentServiceI;
import org.jeecgframework.core.common.service.impl.CommonServiceImpl;
import com.group.entity.patent.PatentEntity;
import java.util.UUID;
import java.io.Serializable;

@Service("patentService")
@Transactional
public class PatentServiceImpl extends CommonServiceImpl implements PatentServiceI {

	
 	public <T> void delete(T entity) {
 		super.delete(entity);
 		//执行删除操作配置的sql增强
		this.doDelSql((PatentEntity)entity);
 	}
 	
 	public <T> Serializable save(T entity) {
 		Serializable t = super.save(entity);
 		//执行新增操作配置的sql增强
 		this.doAddSql((PatentEntity)entity);
 		return t;
 	}
 	
 	public <T> void saveOrUpdate(T entity) {
 		super.saveOrUpdate(entity);
 		//执行更新操作配置的sql增强
 		this.doUpdateSql((PatentEntity)entity);
 	}
 	
 	/**
	 * 默认按钮-sql增强-新增操作
	 * @param id
	 * @return
	 */
 	public boolean doAddSql(PatentEntity t){
	 	return true;
 	}
 	/**
	 * 默认按钮-sql增强-更新操作
	 * @param id
	 * @return
	 */
 	public boolean doUpdateSql(PatentEntity t){
	 	return true;
 	}
 	/**
	 * 默认按钮-sql增强-删除操作
	 * @param id
	 * @return
	 */
 	public boolean doDelSql(PatentEntity t){
	 	return true;
 	}
 	
 	/**
	 * 替换sql中的变量
	 * @param sql
	 * @return
	 */
 	public String replaceVal(String sql,PatentEntity t){
 		sql  = sql.replace("#{id}",String.valueOf(t.getId()));
 		sql  = sql.replace("#{application_no}",String.valueOf(t.getApplicationNo()));
 		sql  = sql.replace("#{patent_type}",String.valueOf(t.getPatentType()));
 		sql  = sql.replace("#{title}",String.valueOf(t.getTitle()));
 		sql  = sql.replace("#{filing_date}",String.valueOf(t.getFilingDate()));
 		sql  = sql.replace("#{case_status}",String.valueOf(t.getCaseStatus()));
 		sql  = sql.replace("#{general_status}",String.valueOf(t.getGeneralStatus()));
 		sql  = sql.replace("#{publication_date}",String.valueOf(t.getPublicationDate()));
 		sql  = sql.replace("#{publication_no}",String.valueOf(t.getPublicationNo()));
 		sql  = sql.replace("#{issue_announcement}",String.valueOf(t.getIssueAnnouncement()));
 		sql  = sql.replace("#{issue_no}",String.valueOf(t.getIssueNo()));
 		sql  = sql.replace("#{applicants}",String.valueOf(t.getApplicants()));
 		sql  = sql.replace("#{inventors}",String.valueOf(t.getInventors()));
 		sql  = sql.replace("#{ip_agency}",String.valueOf(t.getIpAgency()));
 		sql  = sql.replace("#{first_named_attorney}",String.valueOf(t.getFirstNamedAttorney()));
 		sql  = sql.replace("#{updated_at}",String.valueOf(t.getUpdatedAt()));
 		sql  = sql.replace("#{basic_updated_at}",String.valueOf(t.getBasicUpdatedAt()));
 		sql  = sql.replace("#{publication_updated_at}",String.valueOf(t.getPublicationUpdatedAt()));
 		sql  = sql.replace("#{payment_updated_at}",String.valueOf(t.getPaymentUpdatedAt()));
 		sql  = sql.replace("#{UUID}",UUID.randomUUID().toString());
 		return sql;
 	}
}